import BaseCacheData from "~/store/base/baseCacheData";

export default new (class BookStatusCache extends BaseCacheData {
  bookStatus: Array<ForeignKeyModel> = [];
  bookStatusSelectSource: Array<ForeignKeyModel> = [];

  constructor() {
    super();
    this.bookStatus = [
      { value: 0, text: "在位" },
      { value: 1, text: "待借出" },
      { value: 2, text: "借出" },
    ];
    this.bookStatusSelectSource = this.bookStatus;
  }

  getStatusName(statusCode: number) {
    let match = this.bookStatus.filter((x) => x.value === statusCode);
    if (match.length > 0) {
      return match[0].text;
    } else {
      return "未知";
    }
  }

  getStatusStyle(statusCode: number) {
    switch (statusCode) {
      case 0:
        return "success";
      case 1:
        return "warning";
      case 2:
        return "danger";
    }
  }
})();
